import myRequest from '@/utils/request';
import {
  ResponseHlAllData,
  EdrmsTypeDto,
  EdrmsTypeAndStorageDto,
  ServiceStorageDTO,
  CommonArrType,
  BorrowRespDto,
  StorageReportDto,
  BiOverviewDto,
} from './types';

export async function getAll() {
  return myRequest.get<ResponseHlAllData>({
    url: '/edrmscore/api/bi/all',
  });
}

export async function getWeather(cityName:any) {
  return myRequest.get<any>({
    url: `/api/BI/GetWeather?cityName=${cityName}`,
  });
}

export async function getEdrmsTypeList() {
  return myRequest.get<EdrmsTypeDto>({
    url: '/api/BI/GetEdrmsType',
  });
}

export async function getEdrmsTypeAndStorageDetail() {
  return myRequest.get<EdrmsTypeAndStorageDto[]>({
    url: '/api/BI/GetEdrmsTypeAndStorages',
  });
}

export async function GetEdrmsBorrowReport(type: any) {
  return myRequest.get<CommonArrType[]>({
    url: `/api/BI/GetEdrmsBorrowReport?reportType=${type}`,
  });
}

export async function getStorgeTypeReportDtos(type: any) {
  return myRequest.get<StorageReportDto>({
    url: `/api/BI/GetStorgeTypeReportDtos?reportType=${type}`,
  });
}
export async function getServiceStorageDetail() {
  return myRequest.get<ServiceStorageDTO[]>({
    url: '/api/BI/GetServiceStorageDtos',
  });
}

export async function getEdrmsHotSearchWord() {
  return myRequest.get<string[]>({
    url: '/api/BI/getEdrmsHotSearchWord',
  });
}

export async function getOverViewDto() {
  return myRequest.get<BiOverviewDto>({
    url: '/api/BI/getOverViewDto',
  });
}

export async function GetBorrowDetails(page: any) {
  return myRequest.get<BorrowRespDto>({
    url: `/api/BI/GetBorrowDetails?pageIndex=${page.pageIndex}&pageSize=${page.pageSize}`,
  });
}

export async function getSect(curTab: string) {
  let sectId = '';
  if (curTab === 'zb') {
    sectId = '1535137152693800962';
  } else if (curTab === 'jy') {
    sectId = '1535137357719769089';
  } else if (curTab === 'mkh') {
    sectId = '1535137529224859650';
  }
  return myRequest.get({
    url: `/edrmscore/api/bi/get-sect/${sectId}`,
  });
}
